#include "Movie.h"
#pragma once

class MovieCollection {
    private:
		// Variables
        Movie* root; // root of the tree
		int positionCounter; // stored the current poisiton within the tree
		Movie* movieChoice; // choice of selected movie

		// Methods
		// pre: true
		// post: returns all movies in alphabetical order
		void printInAlphabeticalOrder(Movie* item);

		// pre: true
		// post: prints all rented movies of a specified user
		void printAllRentedMovies(Movie* item, std::string userName);

		// pre: true
		// post: checks whether the user currently has a rental
		bool checkUserRentals(Movie* item, std::string userName);

		// pre: true
		// post: searches the tree for a specified movie by title
		void searchByTitle(std::string movieTitle, Movie* item);

		// pre: true
		// post: searches through the tree for movies that is rented by a specific user
		void searchByUser(std::string movieTitle, Movie* item, std::string userName);

		// pre: true
		// post: searches for a specific choice of a movie
		void searchByTitleChoice(std::string movieTitle, int choicePosition, Movie* item);

		// pre: true
		// post: calculated the size of the tree
		int sizeOfMovieCollection(Movie* item);

		// pre: true
		// post: used to get a particular movie
		Movie *getMovieAtPosition(int position);

		// pre: true
		// post: used to get a particular movie
		void MovieCollection::getMovieAtPosition(int position, Movie* item);

		// pre: true
		// post: used to get a particular movie
		Movie *getMovieById(int position);

		// pre: true
		// post: used to get a particular movie
		void MovieCollection::getMovieById(int position, Movie* item);
    
		// pre: true
		// post: do a quicksort algorithm on input arrays
		void popularitySort(int intArray[], int strArray[], int left, int right);

		// pre: true
		// post: quicksort partition to determine the pivot
		int partition(int intArray[], int strArray[], int left, int right, int pivotIndex);
    public:
		// Constructors
        MovieCollection();
		~MovieCollection();
       
		// Methods
		// pre: true
		// post: adds a movie to the tree
		void addMovie(Movie* item);

		// pre: true
		// post: returns all movies in alphabetical order
		void printInAlphabeticalOrder();

		// pre: true
		// post: prints all rented movies of a specified user
		void printAllRentedMovies(std::string userName);

		// pre: true
		// post: checks whether the user currently has a rental
		bool checkUserRentals(std::string userName);

		// pre: true
		// post: gets the renters of a movie
		void getRentersOfMovie(Movie *item);

		// pre: true
		// post: searches the tree for a specified movie by title
		int searchByTitle(std::string movieTitle);

		// pre: true
		// post: searches through the tree for movies that is rented by a specific user
		int searchByUser(std::string movieTitle, std::string userName);

		// pre: true
		// post: searches for a specific choice of a movie
		Movie *searchByTitleChoice(std::string movieTitle, int choicePosition);    

		// pre: true
		// post: determines whether the tree is empty
		bool isEmpty() const;

		// pre: true
		// post: prints the top ten rented movies
		void printTopTen();

		// pre: true
		// post: returns if the number of DVDs of a movie
		int numberOfDvdsInStoreForAMovie(Movie* item);		

		// pre: true
		// post: returns if the number of DVDs of a movie
		int numberOfDvdsOutOfStoreForAMovie(Movie* item);		

		// pre: true
		// post: deletes a movie
		void deleteMovie(std::string movieBinaryId);

};